<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>获取元素对象</title>



</head>
<body>

    <img id="light" src="img/1.png">
    <h1 id="title">绝顶聪明灰太狼</h1>

    <script>
        //通过 id 获取元素对象
        var light = document.getElementById("light");
        alert("我要换图片了。。。");
        light.src = "img/2.png";

        //1.获取 h1 标签对象
        /*var title = document.getElementById("title");
        alert("我要换内容了。。。")
        //2.修改内容
        title.innerHTML = "健步如飞喜羊羊";*/


    </script>
</body>
</html>